// 首页
// http://byapi.szsdyxmy.com/index.htm#/

// 登录
// http://byapi.szsdyxmy.com/index.htm#/pages/login/login

// 接单
// http://byapi.szsdyxmy.com/api/Task/GetMemberTaskList


function setToken() {
    let token = Android.getMap("token")
    token = token.split(",")[0]
    sessionStorage.setItem("token", token)
}
setToken()


function getAndroidToken() {
    let token = localStorage.getItem("token").replace(/^"|"$/g, '');
    let user = localStorage.getItem("userId").replace(/^"|"$/g, '');
    user = JSON.parse(user)
    let userId = user["data"]
    return token + "," + userId
}
getAndroidToken()



// 接单

function getParameterHandler() {
    let token = parameter.getMap("token")
    token = token.split(",")

    let headers = {}
    let body = {
        "UserId": token[1],
        "Token": token[0],
        "MemberAcceptTaskStatus": 1,
        "TaskType": "1",
        "Page": 1,
        "PageSize": 1
    }
    let strUrl = ``
    let url = parameter.getMap("url") + strUrl
    return {
        mediaType: "json",
        requestType: "POST",
        url: url,
        headers: JSON.stringify(headers),
        body: JSON.stringify(body)
    }
}
getParameterHandler()




function getResponse() {
    let res = response.getMap("res")
    let code = "500"
    let message = "接单中"
    let dataKey = ""
    let dataValue = ""


    res = JSON.parse(res)
    if (res["errcode"] == 0 && res["obj"]["AcceptTaskList"] && res["obj"]["AcceptTaskList"].length > 0) {
        code = "200"
        message = "接单成功，请尽快完成"
    } else if (res["errcode"] == 0 && res["obj"]["AcceptTaskList"] && res["obj"]["AcceptTaskList"].length <= 0) {
        code = "500"
        message = "接单中..."
    } else {
        code = "300"
        message = res["msg"]
    }
    return {
        code: code,
        message: message,
        dataKey: dataKey,
        dataValue: dataValue
    }
}
getResponse()


// {
// 	"errcode": 0,
// 	"msg": "",
// 	"url": "",
// 	"obj": {
// 		"AcceptTaskList": [
			
// 		],
// 		"IsNextPage": 0,
// 		"RebateTime": 24,
// 		"ReturnCommissionTime": 24
// 	}
// }